<tagLib name="html"/>
<script language="javascript" src="/Public/static/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<div id="main-content">
    <div id="main" class="main">
        <!-- 修改密码 start -->
        <div class="spin-cont">
            <div class="user-hd">
                <h2>影院管理>>{$page_title}</h2>
            </div>
            <div class="user_zl">
                <form name="data_form" id="data_form" method="POST">
                    <dl class="clearfix">
                        <dt>主机名：</dt>
                        <dd>
                            <if condition="1 EQ $is_add">
                                <input type="text" id="host_name" name="host_name" autocomplete="off" maxlength="66"
                                       placeholder="英文、数字或中划线，最长18位" class="bg-input w229"/>
                                <else/>
                                {$model.host_name}
                            </if>
                        </dd>
                        <dd class="error_message" id="message_host_name"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>vpn影院名称：</dt>
                        <dd>
                            <input type="text" id="vpn_cinema_name" name="vpn_cinema_name" autocomplete="off"  value="{$model.vpn_cinema_name|default=''}" class="bg-input w229" placeholder="" />
                        </dd>
                        <dd class="error_message" id="message_vpn_cinema_name"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>主机IP：</dt>
                        <dd>
                            <input type="text" id="host_ip" name="host_ip" value="{$model.host_ip}" maxlength="66" placeholder="IP地址" autocomplete="off" class="bg-input w229"/>
                        </dd>
                        <dd class="error_message" id="message_host_ip"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>影院地址：</dt>
                        <dd>
                            {:w('Area/multLevel', array(1, '', 1, $model[area_1], $model[area_2], $model[area_3]))}
                        </dd>
                        <dd class="error_message" id="message_area"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>&nbsp;</dt>
                        <dd><input type="text" id="address" name="address" value="{$model.address}" maxlength="40"
                                   placeholder="最长40个字" autocomplete="off" class="bg-input w229"/></dd>
                        <dd class="error_message" id="message_address"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>联系人：</dt>
                        <dd><input type="text" id="contacter" name="contacter" value="{$model.contacter}" maxlength="15"
                                   placeholder="中文或英文，最长15个字" autocomplete="off" class="bg-input w229"/></dd>
                        <dd class="error_message" id="message_contacter"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>手机号码：</dt>
                        <dd><input type="text" id="phone" name="phone" value="{$model.phone}" maxlength="11"
                                   placeholder="请输入11位的手机号" autocomplete="off" class="bg-input w229"/></dd>
                        <dd class="error_message" id="message_phone"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>是否正式启用：</dt>
                        <dd>
                            <html:select options="yes_no_options" name="is_online" id="is_online"
                                         selected="model[is_online]"/>
                        </dd>
                        <dd class="error_message" id="message_is_online"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>计费方式：</dt>
                        <dd>
                            <html:select options="recharge_method_options" name="recharge_method_id"
                                         id="recharge_method_id" selected="model[recharge_method_id]"
                                         change="isMustInputMoneyInfo()"/>
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>所属代理：</dt>
                        <dd>
                            <html:select options="agent_options" name="agent_id" id="agent_id"
                                         selected="model[agent_id]" change="chooseAgentLevel1()"/>
                            <select name="agent_level_1" id="agent_level_1" class="hidden"></select>
                            <select name="agent_level_2" id="agent_level_2" class="hidden"></select>
                            <br/>
                            <input type="hidden" id="current_agent_level_1" value="{$model.agent_level_1}"/>
                            <input type="hidden" id="current_agent_level_2" value="{$model.agent_level_2}"/>
                        </dd>
                        <dd class="error_message" id="message_agent_id"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>影院类型：</dt>
                        <dd>
                            <html:select options="cinema_type_options" name="type" id="type" selected="model[type]"
                                         change="isMustInputMoneyInfo()"/>
                        </dd>
                        <dd class="error_message" id="message_cinema_type"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>是否试用：</dt>
                        <dd>
                            <html:select options="yes_no_options" name="is_try" id="is_try" selected="model[is_try]"
                                         change="isMustInputMoneyInfo()"/>
                        </dd>
                        <dd class="error_message" id="message_is_try"></dd>
                    </dl>
                    <dl class="clearfix try_data_box">
                        <dt>试用截止日期：</dt>
                        <dd>
                            <input type="text" name="try_day_max" id="try_day_max" placeholder="试用截止日期"
                                   value="{$model.try_day_max|default=$default_try_day_max}" class="Wdate bg-input"
                                   onFocus="WdatePicker({})" readonly="readonly" size="30" style="width: 90px;"/>
                        </dd>
                        <dd class="error_message" id="message_try_day_max"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>扣费先后：</dt>
                        <dd>
                            <html:select options="pay_position_options" name="pay_position" id="pay_position"
                                         selected="model[pay_position]"/>
                        </dd>
                        <dd class="error_message" id="message_pay_position"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>授权房间：</dt>
                        <dd>
                            <if condition="(1 NEQ $is_add) AND (0 LT $model[buy_hall_count]) AND (0 LT $model[hall_price])">
                                {$model.buy_hall_count}
                                <input type="hidden" id="buy_hall_count" name="buy_hall_count"
                                       value="{$model.buy_hall_count}" onkeyup="calculatePeriodMoney()"
                                       onblur="calculatePeriodMoney()" maxlength="6" autocomplete="off"
                                       class="bg-input w229"/> 间
                                <else/>
                                <input type="text" id="buy_hall_count" name="buy_hall_count" value="<if condition=" 0 LT $model[buy_hall_count]">{$model.buy_hall_count}</if>" placeholder="最大为数字99" onkeyup="calculatePeriodMoney()" onblur="calculatePeriodMoney()"
                            maxlength="6" autocomplete="off" class="bg-input w229"/> 间
                            </if>
                        </dd>
                        <dd class="error_message" id="message_buy_hall_count"></dd>
                    </dl>
                    <dl class="clearfix accredit_day_end">
                        <dt>授权截止日期：</dt>
                        <dd>
                            <input type="text" name="accredit_day_end" id="accredit_day_end" placeholder="授权截止日期"
                                   value="{$model.accredit_day_end}" class="Wdate bg-input"
                                   onFocus="WdatePicker({})" readonly="readonly" size="30" style="width: 90px;"/>
                        </dd>
                        <dd class="error_message" id="accredit_day_end_txt"></dd>
                    </dl>
                    <dl class="clearfix not_try_data_box">
                        <dt>计费金额：</dt>
                        <dd>
                            <if condition="(1 NEQ $is_add) AND (0 LT $model[hall_price])">
                                {$model.hall_price}
                                <input type="hidden" id="hall_price" name="hall_price" value="{$model.hall_price}"
                                       maxlength="5" onkeyup="calculatePeriodMoney()" onblur="calculatePeriodMoney()"
                                       autocomplete="off" class="bg-input w229"/> 元 / 间 - 月
                                <else/>
                                <input type="text" id="hall_price" name="hall_price" value="<if condition=" 0 LT $model[hall_price]">{$model.hall_price}</if>" maxlength="5" placeholder="最大为数字99999" onkeyup="calculatePeriodMoney()"
                            onblur="calculatePeriodMoney()" autocomplete="off" class="bg-input w229"/> 元 / 间 - 月
                            </if>
                        </dd>
                        <dd class="error_message" id="message_hall_price"></dd>
                    </dl>
                    <dl class="clearfix not_try_data_box">
                        <dt>计费周期：</dt>
                        <dd>
                            <if condition="(1 NEQ $is_add) AND (0 LT $model[period_count])">
                                {$model.period_count}
                                <input type="hidden" id="period_count" name="period_count" value="{$model.period_count}"
                                       onkeyup="calculatePeriodMoney()" onblur="calculatePeriodMoney()" maxlength="2"
                                       autocomplete="off" class="bg-input w229"/> 月
                                <else/>
                                <input type="text" id="period_count" name="period_count" value="<if condition=" 0 LT $model[period_count]">{$model.period_count} </if>" placeholder="最大为数字99" onkeyup="calculatePeriodMoney()" onblur="calculatePeriodMoney()"
                            maxlength="2" autocomplete="off" class="bg-input w229"/> 月
                            </if>
                        </dd>
                        <dd class="error_message" id="message_period_count"></dd>
                    </dl>
                    <dl class="clearfix not_try_data_box">
                        <dt>扣费周期：</dt>
                        <dd>
                            <if condition="(1 NEQ $is_add) AND (0 LT $model[period_count])">
                                {$deduct_period_options[$model[deduct_period]]}
                                <div style="display: none;">
                                    <html:select options="deduct_period_options" name="deduct_period" id="deduct_period"
                                                 change="calculatePeriodMoney()" selected="model[deduct_period]"/>
                                </div>
                                <else/>
                                <html:select options="deduct_period_options" name="deduct_period" id="deduct_period"
                                             change="calculatePeriodMoney()" selected="model[deduct_period]"/>
                            </if>
                        </dd>
                        <dd class="error_message" id="message_deduct_period"></dd>
                    </dl>
                    <dl class="clearfix not_try_data_box">
                        <dt>每期扣费总计：</dt>
                        <dd id="period_money"></dd>
                    </dl>
                    <dl class="clearfix not_try_data_box">
                        <dt>计费总计：</dt>
                        <dd id="total_money"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>备注：</dt>
                        <dd><textarea id="remark" name="remark" class="bg-textarea w229"
                                      maxlength="100">{$model.remark}</textarea></dd>
                    </dl>
                    <if condition="1 NEQ $is_add">
                        <dl class="clearfix">
                            <dt>加盟时间：</dt>
                            <dd>{$model.join_time|date="Y-m-d H:i", ###}</dd>
                        </dl>
                        <dl class="clearfix">
                            <dt>当前余额：</dt>
                            <dd>{$model.money} 元</dd>
                        </dl>
                        <dl class="clearfix">
                            <dt>影厅数量：</dt>
                            <dd>{$model.video_hall_count}</dd>
                        </dl>
                    </if>
                    <dl class="clearfix" id="billing_video_play_type_box">
                        <dt>2016计费方式：</dt>
                        <dd>
                            <html:select options="billing_video_play_type" name="billing_video_play_type"
                                         id="billing_video_play_type" selected="model[billing_video_play_type]"
                                         change="selectBillingVideoPlayType()"/>
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>片库类型：</dt>
                        <dd>
                            <html:select options="video_data_type_options" name="video_data_type" id="video_data_type"
                                         selected="model[video_data_type]"/>
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>片源网络：</dt>
                        <dd>
                            <html:select options="video_net_options" name="video_net" id="video_net" selected="model[video_net]" />
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>影院系统平台：</dt>
                        <dd>
                            <html:select options="system_platform_options" name="system_platform" id="system_platform"
                                         selected="model[system_platform]"/>
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>是否支持本地视频：</dt>
                        <dd>
                            <html:select options="yes_no_options" name="is_support_local_video"
                                         id="is_support_local_video" selected="model[is_support_local_video]"/>
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>影院所在区域：</dt>
                        <dd>
                            <html:select options="video_copyright_area_options" name="video_copyright_area"
                                         id="video_copyright_area" selected="model[video_copyright_area]"/>
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>影院所属行业：</dt>
                        <dd>
                            <html:select options="video_copyright_industry_options" name="video_copyright_industry"
                                         id="video_copyright_industry" selected="model[video_copyright_industry]"/>
                        </dd>
                    </dl>

                    <dl class="clearfix">
                        <dt>限制测试影片数量：</dt>
                        <dd>
                            <input type="text" id="video_limit" name="video_limit" value="<if condition="$model[video_limit]">{$model.video_limit}<else/>0</if>" placeholder="最大为数字30" autocomplete="off" class="bg-input w10"/> 部
                        </dd>
                    </dl>

                    <dl class="clearfix">
                        <dt>
                            签署版权商 <label><input type="checkbox" id="video_film_source_cbx" onclick="checkVideoFilmSource()" /></label>：
                        </dt>
                        <dd>
                            {$video_film_source_options_form}
                        </dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>银行账户名：</dt>
                        <dd>
                            <input type="text" id="bank_card_account" name="bank_card_account"
                                   value="{$model.bank_card_account}" maxlength="36" placeholder="银行账户名"
                                   autocomplete="off" class="bg-input w229"/>
                        </dd>
                        <dd class="error_message" id="message_bank_card_account"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>商户账户属性：</dt>
                        <dd>
                            <html:select options="bank_card_type_options" name="bank_card_type" id="bank_card_type"
                                         selected="model[bank_card_type]"/>
                        </dd>
                        <dd class="error_message" id="message_bank_card_type"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>所属银行：</dt>
                        <dd>
                            <html:select options="bank_options" name="bank_card_bank" id="bank_card_bank"
                                         selected="model[bank_card_bank]"/>
                        </dd>
                        <dd class="error_message" id="message_bank_card_bank"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>账户号码：</dt>
                        <dd>
                            <input type="text" id="bank_card_number" name="bank_card_number"
                                   value="{$model.bank_card_number}" maxlength="36" placeholder="账户号码"
                                   autocomplete="off" class="bg-input w229"/>
                        </dd>
                        <dd class="error_message" id="message_bank_card_number"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt>开户地区：</dt>
                        <dd>
                            <input type="text" id="bank_card_address" name="bank_card_address"
                                   value="{$model.bank_card_address}" maxlength="60" placeholder="开户地区"
                                   autocomplete="off" class="bg-input w229"/>
                        </dd>
                        <dd class="error_message" id="message_bank_card_address"></dd>
                    </dl>
                    <dl class="clearfix">
                        <dt></dt>
                        <dd>
                            <a href="javascript:;" class="gray-btn" onclick="postClick()">确定</a>
                            <a href="javascript:;" class="gray-btn" onclick="reset('data_form')">取消</a>
                            <input type="hidden" name="id" value="{$id}"/>
                            <input type="hidden" name="referer" value="{$Think.config.REFERER}"/>
                        </dd>
                    </dl>
                </form>
            </div>
        </div>
    </div>
</div>
<script language="javascript">
    //是否新增
    is_add = {$is_add};

    //代理商2016计费方式
    var agent_billing_video_play_type = 0;

    $(document).ready(function () {

        //计算金额总计
        calculatePeriodMoney();

        //是否立即数据计费方式
        isMustInputMoneyInfo();

        //默认选择代理信息
        chooseAgentLevel1();

        //默认选择2016计费方式
        selectBillingVideoPlayType();
    });

    function postClick() {
        if($('#vpn_cinema_name').val()==''){
            $('#message_vpn_cinema_name').html('vpn影院名称不能为空');
            $('#vpn_cinema_name').focus();
            return false;
        }

        //判断授权凭证码是否重复
        var auth_code_1 = $('#auth_code_1').val();
        var auth_code_2 = $('#auth_code_2').val();
        if (auth_code_1 == '' && auth_code_2 != '') {
            $('#message_auth_code').html('授权凭证码不完整');
            $('#auth_code_1').focus();
            return false;
        }
        if (auth_code_1 != '' && auth_code_2 == '') {
            $('#message_auth_code').html('授权凭证码不完整');
            $('#auth_code_2').focus();
            return false;
        }
        if (auth_code_1 != "" && auth_code_2 != '') {
            $.get("{:U('Admin/Cinema/checkAuthInfo')}", {
                auth_code_1: auth_code_1,
                auth_code_2: auth_code_2,
                id: "{:I('get.id')}"
            }, function (result) {
                if (result.status_code === 1) {
                    $('#message_auth_code').html('授权凭证码重复，请重新输入');
                    $('#auth_code_1').focus();
                    return false;
                } else {
                    $('#message_auth_code').html('');
                    saveCinemaUser()
                }
            })
        } else {
            $('#message_auth_code').html('');
            saveCinemaUser()
        }
    }

    //选择主代理
    function chooseAgentLevel1() {
        var pid = $('#agent_id').val();
        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '{:U("Common/chooseAgentLevel")}',
            data: {
                pid: pid,
                agent_level: 1
            },
            success: function (data) {
                //获取小影院2016计费方式
                var billing_video_play_type = $('#billing_video_play_type').val();
                //获取代理商2016计费方式，基于所选，更新计费表单展示
                var agent_billing_video_play_type_index = data.indexOf('#');
                agent_billing_video_play_type_index = agent_billing_video_play_type_index + 1;
                agent_billing_video_play_type = data.substr(agent_billing_video_play_type_index, 1);
                data = data.substr(0, agent_billing_video_play_type_index - 1);
                if (0 < billing_video_play_type
                        || 0 < agent_billing_video_play_type) {
                    $('.not_try_data_box').hide();
                    hideMessage('buy_hall_count');
                    hideMessage('hall_price');
                    hideMessage('period_count');
                    hideMessage('deduct_period');
                } else {
                    $('.not_try_data_box').show();
                    hideMessage('buy_hall_count');
                    hideMessage('hall_price');
                    hideMessage('period_count');
                    hideMessage('deduct_period');
                }
                if (0 < agent_billing_video_play_type) {
                    $('#billing_video_play_type').val(0);
                    $('#billing_video_play_type_box').hide();
                } else {
                    $('#billing_video_play_type_box').show();
                }

                $('#agent_level_1').html(data);
                if ('<option value="0"></option>' == data) {
                    $('#agent_level_1').hide();
                    $('#agent_level_2').hide();
                    $('#agent_level_1').html('');
                    $('#agent_level_2').html('');
                } else {
                    $('#agent_level_1').show();
                    $('#agent_level_1').attr('onchange', 'chooseAgentLevel2()');

                    var current_agent_level_1 = $('#current_agent_level_1').val();
                    if (current_agent_level_1) {
                        $('#agent_level_1').val(current_agent_level_1);
                        chooseAgentLevel2();
                    }
                }
            }
        });
    }

    //选择一级代理
    function chooseAgentLevel2() {
        var pid = $('#agent_level_1').val();
        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '{:U("Common/chooseAgentLevel")}',
            data: {
                pid: pid
            },
            success: function (data) {
                $('#agent_level_2').html(data);
                if ('<option value="0"></option>' == data) {
                    $('#agent_level_2').hide();
                    $('#agent_level_2').html('');
                } else {
                    $('#agent_level_2').show();
                    var current_agent_level_2 = $('#current_agent_level_2').val();
                    if (current_agent_level_2) {
                        $('#agent_level_2').val(current_agent_level_2);
                    }
                }
            }
        });
    }
    
    //选择搬寝室
    function checkVideoFilmSource()
    {
        var current_check_status = $('#video_film_source_cbx').prop('checked');
        console.log(current_check_status);
        if (true == current_check_status) {
            $('.copyright_user_ids').prop('checked', true);
        } else {
            $('.copyright_user_ids').prop('checked', false);
        }
    }
</script>